//
// Created by pzw on 24-3-22.
//

#include "FuncObj.h"

void FuncObj::std_func_obj_sort(std::vector<int> &vs) {
    using namespace std;
    sort(vs.begin(), vs.end(), greater<int>{});
}

void FuncObj::std_func_obj_sort2(std::vector<int> &vs) {
    using namespace std;
    sort(vs.begin(), vs.end(), [](int a, int b) -> bool {
        return a > b;
    });
}

int FuncObj_main() {
    using namespace std;
    vector<int> vs{3, 5, 1, 5, 2, 6, 7, 4, 7, 8, 9};
    FuncObj::std_func_obj_sort(vs);
    std::cout << "FuncObj_main: std_func_obj_sort vs = {" << std::endl;
    for_each(vs.begin(), vs.end(), [](int e) {
        std::cout << e << ", ";
    });
    std::cout << std::endl << "}" << std::endl;

    vector<int> vs2{0, 5, 1, 5, 2, 6, 2, 4, 3, 8, 1};
    FuncObj::std_func_obj_sort2(vs2);
    std::cout << "FuncObj_main: std_func_obj_sort2 vs2 = {" << std::endl;
    for_each(vs2.begin(), vs2.end(), [](int e) {
        std::cout << e << ", ";
    });
    std::cout << std::endl << "}" << std::endl;

    return 0;
}
